//
//  ListTableViewCell.m
//  ThePrivateKitchen
//
//  Created by lirui on 16/1/24.
//  Copyright © 2016年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "ListTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "Frame.h"
@interface ListTableViewCell ()

@property(nonatomic, retain) UIImageView *icon;
@property (nonatomic, retain) UILabel *type;
@property (nonatomic, retain) UILabel *title;
@property (nonatomic, retain) UIImageView *pictureLeft;
@property (nonatomic, retain) UIImageView *pictureCenter;
@property (nonatomic, retain) UIImageView *pictureRight;
@property (nonatomic, retain) UIImageView *touxiang;


@end
@implementation ListTableViewCell

- (void)dealloc
{
    [_listModel release];
    [_title release];
    [_icon release];
    [_type release];
    [_pictureLeft release];
    [_pictureRight release];
    [_pictureCenter release];
    [_touxiang release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.icon = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.icon];
        [_icon release];
        
        self.type = [[UILabel alloc]init];
        self.type.backgroundColor = [UIColor yellowColor];
        self.type.font = [UIFont systemFontOfSize:12];
        self.type.textAlignment = NSTextAlignmentCenter;
        
        [self.contentView addSubview:self.type];
        [_type release];
        
        self.title = [[UILabel alloc]init];
        //self.type.backgroundColor = [UIColor yellowColor];
        self.title.font = [UIFont systemFontOfSize:18];
        self.title.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.title];
        [_title release];
        
        self.pictureLeft = [[UIImageView alloc] init];
       // self.pictureLeft.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.pictureLeft];
        [_pictureLeft release];
        
        
        self.pictureCenter = [[UIImageView alloc] init];
       // self.pictureCenter.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.pictureCenter];
        [_pictureLeft release];
        
        
        self.pictureRight = [[UIImageView alloc] init];
        //self.pictureRight.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.pictureRight];
        [_pictureRight release];
        
        self.touxiang = [[UIImageView alloc]init];
        [self.contentView addSubview:self.touxiang];
        self.touxiang.layer.cornerRadius = 22;
        [_touxiang release];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.icon.frame = CGRectMake(15 * WIDTH, 70 *HEIGHT, 22 * WIDTH, 22 * HEIGHT);
    self.type.frame = CGRectMake(15 * WIDTH, 70 * HEIGHT, 22 * WIDTH, 22 * HEIGHT);
    self.title.frame = CGRectMake(15 * WIDTH, 140 * HEIGHT, 375 * WIDTH, 22 *HEIGHT);
    self.pictureLeft.frame = CGRectMake(50 * WIDTH, 10 *HEIGHT, 100 * WIDTH, 100 *HEIGHT);
    self.pictureCenter.frame = CGRectMake(self.pictureLeft.frame.origin.x + 103 * WIDTH, 10 * HEIGHT, 100 * WIDTH, 100 * HEIGHT);
    self.pictureRight.frame = CGRectMake(self.pictureCenter.frame.origin.x + 103 * WIDTH, 10 * HEIGHT, 100 * WIDTH, 100 * HEIGHT);
    self.touxiang.frame = CGRectMake(180 * WIDTH, 88 *HEIGHT, 45 * WIDTH, 45 * HEIGHT);
}

-(void)setListModel:(TopicModel *)listModel
{
   
        if (_listModel != listModel)
        {
            [_listModel  release];
            _listModel = [listModel retain];
       
        }
     self.type.text = listModel.order.stringValue;
     self.title.text = listModel.title;


[self.pictureLeft sd_setImageWithURL:[NSURL URLWithString:listModel.recipe[0]]];

[self.pictureCenter sd_setImageWithURL:[NSURL URLWithString:listModel.recipe[1]]];
[self.pictureRight sd_setImageWithURL:[NSURL URLWithString:listModel.recipe[2]]];
[self.touxiang sd_setImageWithURL:listModel.user_info[@"p"]];

}

@end
